function t(t) {
    return (t = t.toString())[1] ? t : "0" + t;
}

module.exports = {
    formatTime: function(e) {
        var n = (e = new Date(e)).getFullYear(), o = e.getMonth() + 1, r = e.getDate(), u = e.getHours(), i = e.getMinutes(), a = e.getSeconds();
        return [ n, o, r ].map(t).join("-") + " " + [ u, i, a ].map(t).join(":");
    },
    formatTimeMinute: function(e) {
        var n = (e = new Date(e)).getFullYear(), o = e.getMonth() + 1, r = e.getDate(), u = e.getHours(), i = e.getMinutes();
        return [ n, o, r ].map(t).join("-") + " " + [ u, i ].map(t).join(":");
    },
    //例如var date = '2015-03-05 17:59:00.0';
    dateStrChangeTimeTamp(dateStr){
        dateStr = dateStr.substring(0,19);
        dateStr = dateStr.replace(/-/g,'/');
        var timeTamp = new Date(dateStr).getTime();
        return timeTamp;
    },
    //例如var date = '2015-03-05 17:59:00.0';
    dateStrChangeTime(dateStr){
        dateStr = dateStr.substring(0,19);
        dateStr = dateStr.replace(/-/g,'/');
        var timeTamp = new Date(dateStr);
        return timeTamp;
    },
    //把时间戳转成日期格式
    //例如 timeTamp = '1425553097';
    formatTimeTamp(timeTamp){
        var time = new Date(timeTamp*1000);
        var date = ((time.getFullYear())  + "-" +
                    (time.getMonth() + 1) + "-" +
                    (time.getDate()) + " " +
                    (time.getHour()) + ":" +
                    (time.getMinutes()) + ":" +
                    (time.getSeconds()))
        return date;
    }
 
};